---
layout: "default"
title: "Operator: !="
description: "Swift documentation for the '!=' operator."
root: "/v3.1"
---

<code class="language-swift"> operator != {
    associativity 
    precedence 
}</code>

<h3>Declarations</h3>

<div class="declaration" id="func-excleq_-int-rhs_-int">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-excleq_-int-rhs_-int">func !=(<wbr>_:<wbr> Int, rhs: Int)</a>
        
<div class="comment collapse" id="comment-func-excleq_-int-rhs_-int"><div class="p">
    <p>Returns a Boolean value that indicates whether
the two arguments have unequal values.</p>

<p><strong>See Also:</strong> <code>Equatable</code>, <code>Comparable</code></p>

    <h4>Declaration</h4>    
    <code class="language-swift">func !=(lhs: Int, rhs: Int) -&gt; Bool</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-excleq_-int8-rhs_-int8">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-excleq_-int8-rhs_-int8">func !=(<wbr>_:<wbr> Int8, rhs: Int8)</a>
        
<div class="comment collapse" id="comment-func-excleq_-int8-rhs_-int8"><div class="p">
    <p>Returns a Boolean value that indicates whether
the two arguments have unequal values.</p>

<p><strong>See Also:</strong> <code>Equatable</code>, <code>Comparable</code></p>

    <h4>Declaration</h4>    
    <code class="language-swift">func !=(lhs: Int8, rhs: Int8) -&gt; Bool</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-excleq_-int16-rhs_-int16">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-excleq_-int16-rhs_-int16">func !=(<wbr>_:<wbr> Int16, rhs: Int16)</a>
        
<div class="comment collapse" id="comment-func-excleq_-int16-rhs_-int16"><div class="p">
    <p>Returns a Boolean value that indicates whether
the two arguments have unequal values.</p>

<p><strong>See Also:</strong> <code>Equatable</code>, <code>Comparable</code></p>

    <h4>Declaration</h4>    
    <code class="language-swift">func !=(lhs: Int16, rhs: Int16) -&gt; Bool</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-excleq_-int32-rhs_-int32">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-excleq_-int32-rhs_-int32">func !=(<wbr>_:<wbr> Int32, rhs: Int32)</a>
        
<div class="comment collapse" id="comment-func-excleq_-int32-rhs_-int32"><div class="p">
    <p>Returns a Boolean value that indicates whether
the two arguments have unequal values.</p>

<p><strong>See Also:</strong> <code>Equatable</code>, <code>Comparable</code></p>

    <h4>Declaration</h4>    
    <code class="language-swift">func !=(lhs: Int32, rhs: Int32) -&gt; Bool</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-excleq_-int64-rhs_-int64">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-excleq_-int64-rhs_-int64">func !=(<wbr>_:<wbr> Int64, rhs: Int64)</a>
        
<div class="comment collapse" id="comment-func-excleq_-int64-rhs_-int64"><div class="p">
    <p>Returns a Boolean value that indicates whether
the two arguments have unequal values.</p>

<p><strong>See Also:</strong> <code>Equatable</code>, <code>Comparable</code></p>

    <h4>Declaration</h4>    
    <code class="language-swift">func !=(lhs: Int64, rhs: Int64) -&gt; Bool</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-excleq_-uint-rhs_-uint">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-excleq_-uint-rhs_-uint">func !=(<wbr>_:<wbr> UInt, rhs: UInt)</a>
        
<div class="comment collapse" id="comment-func-excleq_-uint-rhs_-uint"><div class="p">
    <p>Returns a Boolean value that indicates whether
the two arguments have unequal values.</p>

<p><strong>See Also:</strong> <code>Equatable</code>, <code>Comparable</code></p>

    <h4>Declaration</h4>    
    <code class="language-swift">func !=(lhs: UInt, rhs: UInt) -&gt; Bool</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-excleq_-uint8-rhs_-uint8">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-excleq_-uint8-rhs_-uint8">func !=(<wbr>_:<wbr> UInt8, rhs: UInt8)</a>
        
<div class="comment collapse" id="comment-func-excleq_-uint8-rhs_-uint8"><div class="p">
    <p>Returns a Boolean value that indicates whether
the two arguments have unequal values.</p>

<p><strong>See Also:</strong> <code>Equatable</code>, <code>Comparable</code></p>

    <h4>Declaration</h4>    
    <code class="language-swift">func !=(lhs: UInt8, rhs: UInt8) -&gt; Bool</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-excleq_-uint16-rhs_-uint16">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-excleq_-uint16-rhs_-uint16">func !=(<wbr>_:<wbr> UInt16, rhs: UInt16)</a>
        
<div class="comment collapse" id="comment-func-excleq_-uint16-rhs_-uint16"><div class="p">
    <p>Returns a Boolean value that indicates whether
the two arguments have unequal values.</p>

<p><strong>See Also:</strong> <code>Equatable</code>, <code>Comparable</code></p>

    <h4>Declaration</h4>    
    <code class="language-swift">func !=(lhs: UInt16, rhs: UInt16) -&gt; Bool</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-excleq_-uint32-rhs_-uint32">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-excleq_-uint32-rhs_-uint32">func !=(<wbr>_:<wbr> UInt32, rhs: UInt32)</a>
        
<div class="comment collapse" id="comment-func-excleq_-uint32-rhs_-uint32"><div class="p">
    <p>Returns a Boolean value that indicates whether
the two arguments have unequal values.</p>

<p><strong>See Also:</strong> <code>Equatable</code>, <code>Comparable</code></p>

    <h4>Declaration</h4>    
    <code class="language-swift">func !=(lhs: UInt32, rhs: UInt32) -&gt; Bool</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-excleq_-uint64-rhs_-uint64">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-excleq_-uint64-rhs_-uint64">func !=(<wbr>_:<wbr> UInt64, rhs: UInt64)</a>
        
<div class="comment collapse" id="comment-func-excleq_-uint64-rhs_-uint64"><div class="p">
    <p>Returns a Boolean value that indicates whether
the two arguments have unequal values.</p>

<p><strong>See Also:</strong> <code>Equatable</code>, <code>Comparable</code></p>

    <h4>Declaration</h4>    
    <code class="language-swift">func !=(lhs: UInt64, rhs: UInt64) -&gt; Bool</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-excleq_-any-type-t1_-any-type">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-excleq_-any-type-t1_-any-type">func !=(<wbr>_:<wbr> Any.Type?, t1: Any.Type?)</a>
        
<div class="comment collapse" id="comment-func-excleq_-any-type-t1_-any-type"><div class="p">
    <p>Returns <code>false</code> iff <code>t0</code> is identical to <code>t1</code>; i.e. if they are both
<code>nil</code> or they both represent the same type.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func !=(t0: Any.Type?, t1: Any.Type?) -&gt; Bool</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-excleq-a-b-where-a_-equatable-b_-equatable_-a-b-rhs_-a-b">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-excleq-a-b-where-a_-equatable-b_-equatable_-a-b-rhs_-a-b">func <wbr>!= &lt;A, B where A :<wbr> Equatable, B : Equatable&gt;(<wbr>_: (<wbr>A, B), rhs: (A, B))</a>
        
<div class="comment collapse" id="comment-func-excleq-a-b-where-a_-equatable-b_-equatable_-a-b-rhs_-a-b"><div class="p">
    <p>Returns a Boolean value indicating whether any corresponding components of
the two tuples are not equal.</p>

<p>For two tuples to compare as equal, each corresponding pair of components
must be equal. The following example compares tuples made up of 2
components:</p>

<pre><code class="language-swift">let a = (&quot;a&quot;, 1)
let b = (&quot;a&quot;, 1)
print(a != b)
// Prints &quot;false&quot;

let c = (&quot;a&quot;, 2)
print(a != c)
// Prints &quot;true&quot;</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> A tuple of <code>Equatable</code> elements.
  <strong>rhs:</strong> Another tuple of elements of the same type as <code>lhs</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func !=&lt;A, B where A : Equatable, B : Equatable&gt;(lhs: (A, B), rhs: (A, B)) -&gt; Bool</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-excleq-a-b-c-where-a_-equatable-b_-equatable-c_-equatable_-a-b-c-rhs_-a-b-c">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-excleq-a-b-c-where-a_-equatable-b_-equatable-c_-equatable_-a-b-c-rhs_-a-b-c">func <wbr>!= &lt;A, B, C where A :<wbr> Equatable, B :<wbr> Equatable, C : Equatable&gt;(<wbr>_: (<wbr>A, B, C), rhs: (A, B, C))</a>
        
<div class="comment collapse" id="comment-func-excleq-a-b-c-where-a_-equatable-b_-equatable-c_-equatable_-a-b-c-rhs_-a-b-c"><div class="p">
    <p>Returns a Boolean value indicating whether any corresponding components of
the two tuples are not equal.</p>

<p>For two tuples to compare as equal, each corresponding pair of components
must be equal. The following example compares tuples made up of 3
components:</p>

<pre><code class="language-swift">let a = (&quot;a&quot;, 1, 2)
let b = (&quot;a&quot;, 1, 2)
print(a != b)
// Prints &quot;false&quot;

let c = (&quot;a&quot;, 1, 3)
print(a != c)
// Prints &quot;true&quot;</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> A tuple of <code>Equatable</code> elements.
  <strong>rhs:</strong> Another tuple of elements of the same type as <code>lhs</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func !=&lt;A, B, C where A : Equatable, B : Equatable, C : Equatable&gt;(lhs: (A, B, C), rhs: (A, B, C)) -&gt; Bool</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-excleq-a-b-c-d-where-a_-equatable-b_-equatable-c_-equatable-d_-equatable_-a-b-c-d-rhs_-a-b-c-d">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-excleq-a-b-c-d-where-a_-equatable-b_-equatable-c_-equatable-d_-equatable_-a-b-c-d-rhs_-a-b-c-d">func <wbr>!= &lt;A, B, C, D where A :<wbr> Equatable, B :<wbr> Equatable, C :<wbr> Equatable, D : Equatable&gt;(<wbr>_: (<wbr>A, B, C, D), rhs: (A, B, C, D))</a>
        
<div class="comment collapse" id="comment-func-excleq-a-b-c-d-where-a_-equatable-b_-equatable-c_-equatable-d_-equatable_-a-b-c-d-rhs_-a-b-c-d"><div class="p">
    <p>Returns a Boolean value indicating whether any corresponding components of
the two tuples are not equal.</p>

<p>For two tuples to compare as equal, each corresponding pair of components
must be equal. The following example compares tuples made up of 4
components:</p>

<pre><code class="language-swift">let a = (&quot;a&quot;, 1, 2, 3)
let b = (&quot;a&quot;, 1, 2, 3)
print(a != b)
// Prints &quot;false&quot;

let c = (&quot;a&quot;, 1, 2, 4)
print(a != c)
// Prints &quot;true&quot;</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> A tuple of <code>Equatable</code> elements.
  <strong>rhs:</strong> Another tuple of elements of the same type as <code>lhs</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func !=&lt;A, B, C, D where A : Equatable, B : Equatable, C : Equatable, D : Equatable&gt;(lhs: (A, B, C, D), rhs: (A, B, C, D)) -&gt; Bool</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-excleq-a-b-c-d-e-where-a_-equatable-b_-equatable-c_-equatable-d_-equatable-e_-equatable_-a-b-c-d-e-rhs_-a-b-c-d-e">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-excleq-a-b-c-d-e-where-a_-equatable-b_-equatable-c_-equatable-d_-equatable-e_-equatable_-a-b-c-d-e-rhs_-a-b-c-d-e">func <wbr>!= &lt;A, B, C, D, E where A :<wbr> Equatable, B :<wbr> Equatable, C :<wbr> Equatable, D :<wbr> Equatable, E : Equatable&gt;(<wbr>_: (<wbr>A, B, C, D, E), rhs: (A, B, C, D, E))</a>
        
<div class="comment collapse" id="comment-func-excleq-a-b-c-d-e-where-a_-equatable-b_-equatable-c_-equatable-d_-equatable-e_-equatable_-a-b-c-d-e-rhs_-a-b-c-d-e"><div class="p">
    <p>Returns a Boolean value indicating whether any corresponding components of
the two tuples are not equal.</p>

<p>For two tuples to compare as equal, each corresponding pair of components
must be equal. The following example compares tuples made up of 5
components:</p>

<pre><code class="language-swift">let a = (&quot;a&quot;, 1, 2, 3, 4)
let b = (&quot;a&quot;, 1, 2, 3, 4)
print(a != b)
// Prints &quot;false&quot;

let c = (&quot;a&quot;, 1, 2, 3, 5)
print(a != c)
// Prints &quot;true&quot;</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> A tuple of <code>Equatable</code> elements.
  <strong>rhs:</strong> Another tuple of elements of the same type as <code>lhs</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func !=&lt;A, B, C, D, E where A : Equatable, B : Equatable, C : Equatable, D : Equatable, E : Equatable&gt;(lhs: (A, B, C, D, E), rhs: (A, B, C, D, E)) -&gt; Bool</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-excleq-a-b-c-d-e-f-where-a_-equatable-b_-equatable-c_-equatable-d_-equatable-e_-equatable-f_-equatable_-a-b-c-d-e-f-rhs_-a-b-c-d-e-f">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-excleq-a-b-c-d-e-f-where-a_-equatable-b_-equatable-c_-equatable-d_-equatable-e_-equatable-f_-equatable_-a-b-c-d-e-f-rhs_-a-b-c-d-e-f">func <wbr>!= &lt;A, B, C, D, E, F where A :<wbr> Equatable, B :<wbr> Equatable, C :<wbr> Equatable, D :<wbr> Equatable, E :<wbr> Equatable, F : Equatable&gt;(<wbr>_: (<wbr>A, B, C, D, E, F), rhs: (A, B, C, D, E, F))</a>
        
<div class="comment collapse" id="comment-func-excleq-a-b-c-d-e-f-where-a_-equatable-b_-equatable-c_-equatable-d_-equatable-e_-equatable-f_-equatable_-a-b-c-d-e-f-rhs_-a-b-c-d-e-f"><div class="p">
    <p>Returns a Boolean value indicating whether any corresponding components of
the two tuples are not equal.</p>

<p>For two tuples to compare as equal, each corresponding pair of components
must be equal. The following example compares tuples made up of 6
components:</p>

<pre><code class="language-swift">let a = (&quot;a&quot;, 1, 2, 3, 4, 5)
let b = (&quot;a&quot;, 1, 2, 3, 4, 5)
print(a != b)
// Prints &quot;false&quot;

let c = (&quot;a&quot;, 1, 2, 3, 4, 6)
print(a != c)
// Prints &quot;true&quot;</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> A tuple of <code>Equatable</code> elements.
  <strong>rhs:</strong> Another tuple of elements of the same type as <code>lhs</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func !=&lt;A, B, C, D, E, F where A : Equatable, B : Equatable, C : Equatable, D : Equatable, E : Equatable, F : Equatable&gt;(lhs: (A, B, C, D, E, F), rhs: (A, B, C, D, E, F)) -&gt; Bool</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-excleq-element-where-element_-equatable_-element-rhs_-element">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-excleq-element-where-element_-equatable_-element-rhs_-element">func <wbr>!= &lt;Element where Element : Equatable&gt;(<wbr>_:<wbr> [Element], rhs: [Element])</a>
        
<div class="comment collapse" id="comment-func-excleq-element-where-element_-equatable_-element-rhs_-element"><div class="p">
    <p>Returns <code>true</code> if the arrays do not contain the same elements.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func !=&lt;Element where Element : Equatable&gt;(lhs: [Element], rhs: [Element]) -&gt; Bool</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-excleq-element-where-element_-equatable_-arrayslice-element-rhs_-arrayslice-element">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-excleq-element-where-element_-equatable_-arrayslice-element-rhs_-arrayslice-element">func <wbr>!= &lt;Element where Element : Equatable&gt;(<wbr>_:<wbr> ArraySlice&lt;Element&gt;, rhs: ArraySlice&lt;Element&gt;)</a>
        
<div class="comment collapse" id="comment-func-excleq-element-where-element_-equatable_-arrayslice-element-rhs_-arrayslice-element"><div class="p">
    <p>Returns <code>true</code> if the arrays do not contain the same elements.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func !=&lt;Element where Element : Equatable&gt;(lhs: ArraySlice&lt;Element&gt;, rhs: ArraySlice&lt;Element&gt;) -&gt; Bool</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-excleq-element-where-element_-equatable_-contiguousarray-element-rhs_-contiguousarray-element">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-excleq-element-where-element_-equatable_-contiguousarray-element-rhs_-contiguousarray-element">func <wbr>!= &lt;Element where Element : Equatable&gt;(<wbr>_:<wbr> ContiguousArray&lt;Element&gt;, rhs: ContiguousArray&lt;Element&gt;)</a>
        
<div class="comment collapse" id="comment-func-excleq-element-where-element_-equatable_-contiguousarray-element-rhs_-contiguousarray-element"><div class="p">
    <p>Returns <code>true</code> if the arrays do not contain the same elements.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func !=&lt;Element where Element : Equatable&gt;(lhs: ContiguousArray&lt;Element&gt;, rhs: ContiguousArray&lt;Element&gt;) -&gt; Bool</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-excleq-t-where-t_-binaryinteger_-t-rhs_-t">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-excleq-t-where-t_-binaryinteger_-t-rhs_-t">func <wbr>!= &lt;T where T : BinaryInteger&gt;(<wbr>_:<wbr> T, rhs: T)</a>
        
<div class="comment collapse" id="comment-func-excleq-t-where-t_-binaryinteger_-t-rhs_-t"><div class="p">
    

    <h4>Declaration</h4>    
    <code class="language-swift">func !=&lt;T where T : BinaryInteger&gt;(lhs: T, rhs: T) -&gt; Bool</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-excleq-t-where-t_-equatable-t_-rawrepresentable-t-rawvalue_-equatable_-t-rhs_-t">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-excleq-t-where-t_-equatable-t_-rawrepresentable-t-rawvalue_-equatable_-t-rhs_-t">func <wbr>!= &lt;T where T :<wbr> Equatable, T :<wbr> RawRepresentable, T.RawValue : Equatable&gt;(<wbr>_:<wbr> T, rhs: T)</a>
        
<div class="comment collapse" id="comment-func-excleq-t-where-t_-equatable-t_-rawrepresentable-t-rawvalue_-equatable_-t-rhs_-t"><div class="p">
    <p>Returns a Boolean value indicating whether the two arguments are not equal.</p>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> A raw-representable instance.
  <strong>rhs:</strong> A second raw-representable instance.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func !=&lt;T where T : Equatable, T : RawRepresentable, T.RawValue : Equatable&gt;(lhs: T, rhs: T) -&gt; Bool</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-excleq-t-where-t_-equatable_-t-rhs_-t">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-excleq-t-where-t_-equatable_-t-rhs_-t">func <wbr>!= &lt;T where T : Equatable&gt;(<wbr>_:<wbr> T, rhs: T)</a>
        
<div class="comment collapse" id="comment-func-excleq-t-where-t_-equatable_-t-rhs_-t"><div class="p">
    <p>Returns a Boolean value indicating whether two values are not equal.</p>

<p>Inequality is the inverse of equality. For any values <code>a</code> and <code>b</code>, <code>a != b</code>
implies that <code>a == b</code> is <code>false</code>.</p>

<p>This is the default implementation of the not-equal-to operator (<code>!=</code>)
for any type that conforms to <code>Equatable</code>.</p>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> A value to compare.
  <strong>rhs:</strong> Another value to compare.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func !=&lt;T where T : Equatable&gt;(lhs: T, rhs: T) -&gt; Bool</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-excleq-t-where-t_-equatable_-t-rhs_-t">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-excleq-t-where-t_-equatable_-t-rhs_-t">func <wbr>!= &lt;T where T : Equatable&gt;(<wbr>_:<wbr> T?, rhs: T?)</a>
        
<div class="comment collapse" id="comment-func-excleq-t-where-t_-equatable_-t-rhs_-t"><div class="p">
    <p>Returns a Boolean value indicating whether two optional instances are not
equal.</p>

<p>Use this not-equal-to operator (<code>!=</code>) to compare any two optional instances
of a type that conforms to the <code>Equatable</code> protocol. The comparison
returns <code>true</code> if only one of the arguments is <code>nil</code> or if the two
arguments wrap values that are not equal. The comparison returns <code>false</code>
if both arguments are <code>nil</code> or if the two arguments wrap values that are
equal.</p>

<pre><code class="language-swift">let group1 = [2, 4, 6, 8, 10]
let group2 = [1, 3, 5, 7, 9]
if group1.first != group2.first {
    print(&quot;The two groups start differently.&quot;)
}
// Prints &quot;The two groups start differently.&quot;</code></pre>

<p>You can also use this operator to compare a non-optional value to an
optional that wraps the same type. The non-optional value is wrapped as an
optional before the comparison is made. In this example, the
<code>numberToMatch</code> constant is wrapped as an optional before comparing to the
optional <code>numberFromString</code>:</p>

<pre><code class="language-swift">let numberToFind: Int = 23
let numberFromString: Int? = Int(&quot;not-a-number&quot;)      // nil
if numberToFind != numberFromString {
    print(&quot;No match.&quot;)
}
// Prints &quot;No match.&quot;</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> An optional value to compare.
  <strong>rhs:</strong> Another optional value to compare.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func !=&lt;T where T : Equatable&gt;(lhs: T?, rhs: T?) -&gt; Bool</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-excleq-t-where-t_-rawrepresentable-t-rawvalue_-equatable_-t-rhs_-t">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-excleq-t-where-t_-rawrepresentable-t-rawvalue_-equatable_-t-rhs_-t">func <wbr>!= &lt;T where T :<wbr> RawRepresentable, T.RawValue : Equatable&gt;(<wbr>_:<wbr> T, rhs: T)</a>
        
<div class="comment collapse" id="comment-func-excleq-t-where-t_-rawrepresentable-t-rawvalue_-equatable_-t-rhs_-t"><div class="p">
    <p>Returns a Boolean value indicating whether the two arguments are not equal.</p>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> A raw-representable instance.
  <strong>rhs:</strong> A second raw-representable instance.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func !=&lt;T where T : RawRepresentable, T.RawValue : Equatable&gt;(lhs: T, rhs: T) -&gt; Bool</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-excleq-t-u-where-t_-binaryinteger-u_-binaryinteger_-t-rhs_-u">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-excleq-t-u-where-t_-binaryinteger-u_-binaryinteger_-t-rhs_-u">func <wbr>!= &lt;T, U where T :<wbr> BinaryInteger, U : BinaryInteger&gt;(<wbr>_:<wbr> T, rhs: U)</a>
        
<div class="comment collapse" id="comment-func-excleq-t-u-where-t_-binaryinteger-u_-binaryinteger_-t-rhs_-u"><div class="p">
    

    <h4>Declaration</h4>    
    <code class="language-swift">func !=&lt;T, U where T : BinaryInteger, U : BinaryInteger&gt;(lhs: T, rhs: U) -&gt; Bool</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-excleq-t_-optionalnilcomparisontype-rhs_-t">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-excleq-t_-optionalnilcomparisontype-rhs_-t">func != &lt;T&gt;(<wbr>_:<wbr> _OptionalNilComparisonType, rhs: T?)</a>
        
<div class="comment collapse" id="comment-func-excleq-t_-optionalnilcomparisontype-rhs_-t"><div class="p">
    <p>Returns a Boolean value indicating whether the right-hand-side argument is
not <code>nil</code>.</p>

<p>You can use this not-equal-to operator (<code>!=</code>) to test whether an optional
instance is not <code>nil</code> even when the wrapped value&#39;s type does not conform
to the <code>Equatable</code> protocol.</p>

<p>The following example declares the <code>stream</code> variable as an optional
instance of a hypothetical <code>DataStream</code> type. Although <code>DataStream</code> is not
an <code>Equatable</code> type, this operator allows checking whether <code>stream</code> wraps
a value and is therefore not <code>nil</code>.</p>

<pre><code class="language-swift">var stream: DataStream? = fetchDataStream()
if nil != stream {
    print(&quot;The data stream has been configured.&quot;)
}
// Prints &quot;The data stream has been configured.&quot;</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> A <code>nil</code> literal.
  <strong>rhs:</strong> A value to compare to <code>nil</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func !=&lt;T&gt;(lhs: _OptionalNilComparisonType, rhs: T?) -&gt; Bool</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-excleq-t_-t-rhs_-optionalnilcomparisontype">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-excleq-t_-t-rhs_-optionalnilcomparisontype">func != &lt;T&gt;(<wbr>_:<wbr> T?, rhs: _OptionalNilComparisonType)</a>
        
<div class="comment collapse" id="comment-func-excleq-t_-t-rhs_-optionalnilcomparisontype"><div class="p">
    <p>Returns a Boolean value indicating whether the left-hand-side argument is
not <code>nil</code>.</p>

<p>You can use this not-equal-to operator (<code>!=</code>) to test whether an optional
instance is not <code>nil</code> even when the wrapped value&#39;s type does not conform
to the <code>Equatable</code> protocol.</p>

<p>The following example declares the <code>stream</code> variable as an optional
instance of a hypothetical <code>DataStream</code> type. Although <code>DataStream</code> is not
an <code>Equatable</code> type, this operator allows checking whether <code>stream</code> wraps
a value and is therefore not <code>nil</code>.</p>

<pre><code class="language-swift">var stream: DataStream? = fetchDataStream()
if stream != nil {
    print(&quot;The data stream has been configured.&quot;)
}
// Prints &quot;The data stream has been configured.&quot;</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> A value to compare to <code>nil</code>.
  <strong>rhs:</strong> A <code>nil</code> literal.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func !=&lt;T&gt;(lhs: T?, rhs: _OptionalNilComparisonType) -&gt; Bool</code>
    
    
</div></div>
</div>
